# 生成 Excel 工资条
from openpyxl import load_workbook, Workbook


def create_excel():
    wb = load_workbook('../02.py_excelFile/工资条.xlsx')
    sh = wb.active

    title = ['工号', '姓名', '部门', '基本工资', '提成', '加班工资', '社保扣除', '考勤扣除', '应发工资', '邮箱']
    # 按照行数 max_row
    for i, row in enumerate(sh.rows):
        if i == 0:
            continue
        else:
            temp_wbook = Workbook()
            temp_sh = temp_wbook.active
            temp_sh.append(title)
            row_data = [cell.value for cell in row]
            if row_data[1] == None:
                continue
            temp_sh.append(row_data)
            temp_wbook.save(f'../02.py_excelFile/{row_data[1]}.xlsx')


if __name__ == '__main__':
    create_excel()

